<?php

/**
 * PCRE — 正则表达式(兼容 Perl)
 * 模式修饰符 i (PCRE_CASELESS)如果设置了这个修饰符，模式中的字母会进行大小写不敏感匹配
 * 元字符
 * https://www.runoob.com/regexp/regexp-metachar.html
 * https://cloud.tencent.com/developer/article/1435804
 */

$pattern = '/[^a-zA-Z0-9\' ]/';
$subject = "cafe's   hello";
$match = preg_match($pattern, $subject, $matches);
$result = match ($match) {
    false => preg_last_error_msg(),
    0 => 'the pattern does not match',
    1 => 1,
};
if ($result === 1) {
    var_dump($matches);
} else {
    echo ($result), PHP_EOL;
}


